
# todo: ==================== 业务数据首日（第一次）同步 ====================

# ======================================================================
#                       省份表：base_province（特殊，同步一次）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_province/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  name,
  region_id,
  area_code,
  iso_code,
  iso_3166_2
FROM base_province
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                       区域表：base_region（特殊，同步一次）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_region/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  region_name
FROM base_region
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                      编码字典表：base_dic（全量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_dic/2023-09-01 \
--delete-target-dir \
--query "SELECT
  dic_code,
  dic_name,
  parent_code,
  create_time,
  operate_time
FROM base_dic
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                      订单详情表：order_detail（增量，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_detail/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  order_id,
  sku_id,
  sku_name,
  order_price,
  sku_num,
  create_time,
  source_type,
  source_id,
  split_total_amount,
  split_activity_amount,
  split_coupon_amount
FROM order_detail
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                      订单表：order_info（新增和变化，每日）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/order_info/2023-09-01 \
--delete-target-dir \
--query "SELECT
  id,
  total_amount,
  order_status,
  user_id,
  payment_way,
  delivery_address,
  out_trade_no,
  create_time,
  operate_time,
  expire_time,
  tracking_no,
  province_id,
  activity_reduce_amount,
  coupon_reduce_amount,
  original_total_amount,
  feight_fee,
  feight_fee_reduce
FROM order_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


